<include file="Public/header" title="生成账号" />
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.1.3/jquery.min.js"></script>
<div id="page-wrapper">
    <ol class="breadcrumb">
        <li class="breadcrumb-item">
          <a href="./admin.php">首页</a>
        </li>
        <li class="breadcrumb-item active">生成账号</li>
      </ol>
    <div class="row">
        <div class="col-lg-12">
            
        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <a href="{:U('Users/add')}" class="btn btn-success">生成账号</a>
        </div>
    </div>
    <table class="table table-hover table-striped" style="margin-top:30px;">
        <thead>
            <tr>
                <th>序号</th>
                <th>用户名</th>
                <!-- <th>密码</th> -->
                <th>生成时间</th>
                <th>状态</th>
               <!--  <th>题目类型</th>
                <th>综合题ID</th>
                <th>题目图片</th> -->
                

                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <foreach name="data" item="v">
              <tr >
                    <td>{$v.id}</td>
                    <td>{$v.username}</td>
                 <!--    <td>{$v.pwd}</td> -->
                    <td>{$v.reg_time}</td>
                    <td class='status'>{$v['status']==0?'正常':'禁止'}</td>
                   <!--  <td>{$v.question_type }</td>
                    <td>{$v.comprehensive_id }</td>
                    
                    <td>{$v.has_img }</td> -->
                     <td> <a href="{:U('Users/delete?id=')}{$v.id}" style="color:red;" onclick="javascript:return del('您真的确定要删除吗？\n\n删除后将不能恢复!');">删除</a></td>
                  <!--   <td>
                        <a href="##" ids="{$v.id}" class="getid"    style="cursor: pointer;">禁止</a>
                        <a href="##" ids="{$v.id}" class="getid1"    style="cursor: pointer;">恢复</a>
                        <a href="##" ids="{$v.id}" class="getid2"    style="cursor: pointer;">删除</a>
                    </td> -->
                </tr>
            </foreach>


        </tbody>
    </table>
    <div class="clearfix"></div>
    {$page}
    
</div>
<script type="text/javascript">
   
   
        //  $(".getid").click(function(){
        //     var status=$(this).attr('status');
        //     var ids=$(this).attr('id');
        //     var that = this;
        //    // alert(status);
        //     $.post(
        //     "{:U('Users/update')}",
        //     {status:status,id:ids},
        //     function(res){
        //         console.log(res)
        //         if(res.code==100){
        //             $(that).attr('status',0);
        //
        //             $(that).html('恢复');
        //             alert(res.msg);
        //         }
        //         if(res.code==101){
        //              $(that).attr('status',1);
        //              $(that).html('禁止');
        //              alert(res.msg);
        //         }
        //     }
        // );
        // })
        $(function () {
            $(".getid2").click(function(){
                var ids=$(this).attr('ids');
                console.log(ids)
                var that = this;
                $.post("{:U('Users/delete')}",{id:ids},
                    function(res){
                        console.log(res)
                        if(res.code==10000){
                            alert(res.msg)
                            // $(this).parent()
                            $(that).parents("tr").remove();
                        }

                    }
                )
            })


             $(".getid").click(function(){
                var ids=$(this).attr('ids');
                console.log(ids)
                var that = this;
                $.post("{:U('Users/update')}",{id:ids,status:1},
                    function(res){
                        console.log(res)
                        if(res.code==100){
                            alert(res.msg)
                            // $(this).parent()
                            // $(that).parents("tr").remove();
                            $('.status').html('禁止');
                        }

                    }
                )
            })


             $(".getid1").click(function(){
                var ids=$(this).attr('ids');
                console.log(ids)
                var that = this;
                $.post("{:U('Users/update')}",{id:ids,status:0},
                    function(res){
                        console.log(res)
                        if(res.code==101){
                            alert(res.msg)
                             $('.status').html('恢复');
                            // $(this).parent()
                            // $(that).parents("tr").remove();

                        }

                    }
                )
            })
        })



</script>
<include file="Public/footer" />